package com.jar.exercise.关于String的面试题;

/**
 * @author 松鼠
 * @className Demo1
 * @description TODO
 * @date 2019-10-10 14:25
 */
public class Demo {
	public static void main(String[] args) {
		String s = "I follow Bill Gate.Tom Gate.John Gate";
		System.out.println(s);
		System.out.println(s.replaceAll("Gate", "Gates"));
	}

	/**
	 * @param s1
	 * @return java.lang.String
	 * @description 反转字符串
	 * @author ZhangShengHao
	 * @date 2019/10/10 14:30
	 */
	public static String reverse(String s1) {
		StringBuffer sb = new StringBuffer();
		char[] chars = s1.toCharArray();
		for (int i = chars.length - 1; i >= 0; i--) {
			sb.append(chars[i]);
		}
		return sb.toString();
	}

	public static String replaceAll(String s1) {
		return s1.replaceAll("Gate", "Gates");
	}
}
